package jmine.tec.test.metric.performance;

import static jmine.tec.test.metric.performance.TestsBuilder.umTest;

import java.util.ArrayList;
import java.util.List;

import jmine.tec.test.Builder;

/**
 * @author bruno.ortiz
 */
public class ReportBuilder implements Builder<Report> {

    private String name;

    private String categ;

    private List<Builder<Tests>> tests = new ArrayList<Builder<Tests>>();

    /**
     * @return ReportBuilder
     */
    public static ReportBuilder umReport() {
        return new ReportBuilder();
    }

    /**
     * @param value value
     * @return this
     */
    public ReportBuilder chamado(String value) {
        this.name = value;
        return this;
    }

    /**
     * @param value value
     * @return this
     */
    public ReportBuilder paraACategoria(String value) {
        this.categ = value;
        return this;
    }

    /**
     * @param umTest umTest
     * @return this
     */
    public ReportBuilder comUmTeste(Builder<Tests> umTest) {
        this.tests.add(umTest);
        return this;
    }

    /**
     * @return report
     */
    public Report build() {
        List<Tests> testes = new ArrayList<Tests>();
        for (Builder<Tests> test : this.tests) {
            testes.add(test.build());
        }
        if (testes.isEmpty()) {
            testes.add(umTest().build());
        }
        return new Report(this.name, this.categ, testes);
    }

}
